Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 015dcc563146fd601afd9f9a5c5e2dfa5e3a5399


Parents : 537f182
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-09-06T19:55:18+02:00

Extract announced stamp cost in handlers

Changes

1 files changed, 10 insertions(+), 1 deletions(-)


Diff

diff --git a/LXMF/Handlers.py b/LXMF/Handlers.py
index c09bf1c..a33d13d 100644
--- a/LXMF/Handlers.py
+++ b/LXMF/Handlers.py
@@ -2,13 +2,14 @@ import time
import RNS
import RNS.vendor.umsgpack as msgpack
-from .LXMF import APP_NAME
+from .LXMF import APP_NAME, stamp_cost_from_app_data
from .LXMessage import LXMessage
class LXMFDeliveryAnnounceHandler:
def __init__(self, lxmrouter):
self.aspect_filter = APP_NAME+".delivery"
+ self.receive_path_responses = True
self.lxmrouter = lxmrouter
def received_announce(self, destination_hash, announced_identity, app_data):
@@ -22,10 +23,18 @@ class LXMFDeliveryAnnounceHandler:
self.lxmrouter.process_outbound()
+ try:
+ stamp_cost = stamp_cost_from_app_data(app_data)
+ if stamp_cost != None:
+ self.lxmrouter.update_stamp_cost(destination_hash, stamp_cost)
+ except Exception as e:
+ RNS.log(f"An error occurred while trying to decode announced stamp cost. The contained exception was: {e}", RNS.LOG_ERROR)
+
class LXMFPropagationAnnounceHandler:
def __init__(self, lxmrouter):
self.aspect_filter = APP_NAME+".propagation"
+ self.receive_path_responses = False
self.lxmrouter = lxmrouter
def received_announce(self, destination_hash, announced_identity, app_data):


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────